{% extends "automan/template.html" %}
{% load staticfiles %}
{% block title %}发布历史列表{% endblock %}

{% block content %}
<div>
    <span class="select-box inline r">
        {% include "automan/filter.html" %}
        <button type="submit" class="btn btn-success filter_btn" >过滤</button>
        {% include "automan/search.html" %}
    </span>
</div><br/><br/>

<table class="table table-border table-bordered table-bg">
    <thead>
        <th>发布单名称</th>
        <th>所属APP</th>
        <th>环境</th>
        <th>部署类型</th>
        <th>操作内容</th>
        <th>用户</th>
        <th>更新时间</th>
    </thead>
    <tbody>
        {% for item in object_list %}
        <tr class="text-l">
            <td>{{ item.deploy_name }}</td>
            <td>{{ item.app_name }}</td>
            <td>{{ item.env_name }}</td>
            <td>
                {% ifequal item.do_type "DEPLOY" %}
                <span class="label label-primary radius">软件部署</span>
                {% else %}
                <span class="label label-success radius">服务启停</span>
                {% endifequal %}
            </td>
            <td>{{ item.content }}</td>
            <td>{{ item.user }}</td>
            <td>{{ item.change_date }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>
<br/>
{#分页    #}
{% include "automan/paginate.html" %}
{% endblock %}

{% block script %}
<script>
$(".search_btn").click(function () {
    var search_pk = $("input[name='search_pk']").val() || "demo";
    if (search_pk == "demo") {
        $("body").Huimodalalert({content: "<span class='c-error'>请输入关键字再进行搜索!", speed: 3000});
        return false;
    }
    search_pk = search_pk.replace(/(^\s*)|(\s*$)/g, "");
    var url = "{% url 'deploy:history' %}?search_pk=" + search_pk;
    console.log(url);
    location.href = url;
});
$(".filter_btn").click(function () {
    var filter_app_name = $("select[name='app_name']").val();
    console.log(filter_app_name);
    if (filter_app_name.length == 0) {
        $("body").Huimodalalert({content: "<span class='c-error'>请选择组件再过滤！</span>", speed: 3000});
        return false;
    } else {
        var url = "{% url 'deploy:history' %}?app_name=" + filter_app_name;
    }
    console.log(url);
    location.href = url;
});
</script>
{% endblock %}